<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>JSP Page</title>
		<link rel="stylesheet" type="text/css" href="../js/easyui/themes/default/easyui.css">

		<link rel="stylesheet" type="text/css" href="../js/easyui/themes/icon.css">

		<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>

		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>

		<script src="../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<!-- 引入 ztree -->
		<script src="../js/ztree/jquery.ztree.all-3.5.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../js/ztree/zTreeStyle.css" />

		<script type="text/javascript">
			$(function() {
				var setting = {
					data: {
						simpleData: {
							enable: true // 支持简单json数据格式
						}
					},

					callback: {
						onClick: function(event, treeId, treeNode, clickFlag) {
							var content = '<div style="width:100%;height:100%;overflow:hidden;">' +
								'<iframe src="' +
								treeNode.page +
								'" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';

							// 没有page树形菜单，不打开选项卡
							if(treeNode.page != undefined && treeNode.page != "") {
								// 如果选项卡已经打开，选中 
								if($("#mytabs").tabs('exists', treeNode.name)) {
									// 选中选项卡
									$("#mytabs").tabs('select', treeNode.name);
								} else {
									// 如果没有打开，添加选项卡 
									$("#mytabs").tabs('add', {
										title: treeNode.name,
										content: content,
										closable: true
									});
								}
							}
						}
					}
				};
				var zNodes = [
					{ id: 1, pId: 0, name: "父节点一" },
					{ id: 2, pId: 0, name: "父节点二" },
					{ id: 11, pId: 1, name: "子节点一" },
					{ id: 12, pId: 1, name: "子节点二" },
					{ id: 13, pId: 1, name: "子节点三" },
					{ id: 14, pId: 1, name: "子节点四" },
					{ id: 21, pId: 2, name: "百度", page: "https://www.baidu.com" },
					{ id: 22, pId: 2, name: "子节点二" }

				];

				// 3、生成菜单
				$.fn.zTree.init($("#baseMenu"), setting, zNodes);

				// 对选项卡注册 右键事件
				$("#mytabs").tabs({
					onContextMenu: function(e, title, index) {
						// 阻止默认菜单显示
						e.preventDefault();

						// 显示自定义右键菜单
						$("#mm").menu('show', {
							left: e.pageX,
							top: e.pageY
						});
					}
				});
				$("#myClose").click(function() {
					var tab = $('#mytabs').tabs('getSelected');
					var index = $('#mytabs').tabs('getTabIndex', tab);
					$('#mytabs').tabs('close', index);
				});
				$("#otherClose").click(function() {
					var tab = $('#mytabs').tabs('getSelected');
					var index = $('#mytabs').tabs('getTabIndex', tab);
					var tabs = $('#mytabs').tabs('tabs');
					for(var i = 0; i < tabs.length; i++) {
						if(index != i) {
							$('#mytabs').tabs('close', i);
							index = $('#mytabs').tabs('getTabIndex', tab);
							i = 0;
						}
					}

				});

			});
			/*// 消息将显示在顶部中间
			$.messager.show({
				title: '我的消息',
				msg: '消息将在4秒后关闭。',
				showType: 'show',
				style: {
					right: '',
					top: document.body.scrollTop + document.documentElement.scrollTop,
					bottom: ''
				}
			});*/
			/*$.messager.show({
				width: '400',
				height: '200',
				title: '<font color="red">安全警告</font>',
				msg: '<h2><font color="red">电脑将在5秒后爆炸 ! 请尽快离开!.......</font></h2>',
				timeout: 5000,
				showType: 'slide'

			});
			window.setTimeout(
				$.messager.progress({
					text: '<font color="red">销毁进度...</font>'
				}), 5000
			);
			window.setTimeout(
				"$.messager.progress('close');", 10000
			);
*/
			/*$.messager.progress({
					text:'销毁进度...'
			});
			$.messager.prompt('提示信息', '请输入你的姓名：', function(r) {
				if(r) {
					alert('你的姓名是：' + r);
				}
			});*/

			/*$.messager.alert('警告', '警告消息');
			$.messager.confirm('确认', '您确认想要删除记录吗？', function(r) {
				if(r) {
					alert('确认删除');
				}
			});*/
		</script>

	</head>

	<body class="easyui-layout">

		<div data-options="region:'north',title:'bos2.0系統',split:true" style="height:100px;">
			<a href="javascript:void(0)" id="mb" class="easyui-menubutton" data-options="menu:'#mms',iconCls:'icon-edit'">Edit</a>
			<div id="mms" style="width:150px;">
				<div data-options="iconCls:'icon-undo'">Undo</div>
				<div data-options="iconCls:'icon-redo'">Redo</div>
				<div class="menu-sep"></div>
				<div>Cut</div>
				<div>Copy</div>
				<div>Paste</div>
				<div class="menu-sep"></div>
				<div data-options="iconCls:'icon-remove'">Delete</div>
				<div>Select All</div>
			</div>
			<!--<div id="win" class="easyui-window" title="我的窗口" style="width:400px;height:200px" data-options="iconCls:'',modal:true">
				风萧萧兮易水寒,啊   易水寒....
			</div>-->
		</div>

		<div data-options="region:'south',title:'South Title',split:true" style="height:100px;">

		</div>

		<div data-options="region:'east',iconCls:'icon-reload',title:'East',split:true" style="width:100px;"></div>

		<div data-options="region:'west',title:'菜单导航',split:true" style="width:200px;">

			<div id="aa" class="easyui-accordion" data-options="fit:'true'" style="width:200px;height:200px;">

				<div title="基本功能" data-options="iconCls:''" style="overflow:auto;padding:10px;">

					<ul id="baseMenu" class="ztree"></ul>

				</div>

				<div title="系统管理" data-options="iconCls:'',selected:true" style="padding:10px;">

					content2

				</div>

			</div>

		</div>

		<div data-options="region:'center',title:'中心消息'" style="padding:5px;background:#eee;">

			<div id="mytabs" class="easyui-tabs" data-options="fit:true">

				<div title="Tab1" data-options="closable:true" style="padding:20px;display:none;">tab1 </div>

				<div title="Tab2" data-options="closable:true" style="overflow:auto;padding:20px;display:none;">tab2 </div>

				<div title="Tab3" data-options="iconCls:'icon-reload',closable:true" style="padding:20px;display:none;">tab3 </div>

				<!-- 菜单 初始化都是隐藏的-->
				<div id="mm" class="easyui-menu" style="width:120px;">
					<div id="myClose">关闭当前窗口</div>
					<div id="otherClose">关闭其它窗口</div>
					<div class="menu-sep"></div>
					<!-- 分隔线 -->
					<div id="allClose" data-options="iconCls:'icon-cancel'">关闭全部窗口</div>
				</div>

			</div>

		</div>

	</body>

</html>